//注册事件
$("#register").click(function() {
	$("#form_title").html("注册");
	$("#login_form").css("display","none");
	$("#register_form").css("display","block");
});
//登录事件
$("#login").click(function() {
	$("#form_title").html("登录");
	$("#register_form").css("display","none");
	$("#login_form").css("display","block");
});

layui.use('layer', function() {
	var layer = layui.layer;
	var $ = layui.jquery;
	//表单验证
	$("#login_form").submit(function() {
		var currentCode = show_num.join("");
		var nowCode=$("#checkCode").val();
		//不区分大小写
		currentCode=currentCode.toLowerCase();
		nowCode=nowCode.toLowerCase();
		if($("#username").val()==""){
			layer.msg('用户名不能为空', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
			return false;
		}else if($("#password").val()==""){
			layer.msg('密码不能为空', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
			return false;
		}else if(currentCode!=nowCode){
			layer.msg('验证码错误', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
			draw(show_num);
			return false;
		}
		return true;
	});
	$("#register_form").submit(function() {
		$("#username11").val($("#username1").val());
		$("#password11").val($("#password1").val());
		var emailText=$("#email").val();
		var emailPatt=/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
		if($("#username1").val()==""){
			layer.msg('用户名不能为空', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
			return false;
		}else if($("#password1").val()==""){
			layer.msg('密码不能为空', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
			return false;
		}else if($("#password2").val()==""){
			layer.msg('重新输入的密码不能为空', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
			return false;
		}else if($("#password1").val()!=$("#password2").val()){
			layer.msg('两次输入的密码不一样', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
			return false;
		}else if($("#email").val()==""){
			layer.msg('邮箱不能为空', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
			return false;
		}
		return true;
	});
});